package com.gxa.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.LayR;
import com.gxa.mapper.CustomerCareMapper;
import com.gxa.param.MyTableParam;
import com.gxa.pojo.Customer;
import com.gxa.service.CustomerCareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Throwable.class)
public class CustomerCareServiceImpl implements CustomerCareService {
    @Autowired
    private CustomerCareMapper customerCareMapper;
    @Override
    public LayR list(MyTableParam param) {
        PageHelper.startPage(param.getPage(),param.getLimit());

        List<Customer> customers = customerCareMapper.findAll(param);

        PageInfo<Customer> customerPageInfo = new PageInfo<>(customers);

        return new LayR(0,"success",customerPageInfo.getList(),customerPageInfo.getTotal());
    }
    public LayR findAll() {
        List<Customer> all=customerCareMapper.findAll();

        return new LayR(200,"success",all);
    }
}
